#include "viewpanel.h"
#include "ui_viewpanel.h"
#include "glpanel.h"
#include <qlayout.h>

ViewPanel::ViewPanel(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::ViewPanel),
    c( NULL )
{
    ui->setupUi(this);

    // Create our OpenGL widget
    c = new GLPanel( ui->frame, "glbox");
    // Put the GL widget inside the frame
    QHBoxLayout* flayout = new QHBoxLayout( ui->frame );
    flayout->addWidget( c, 1 );

    // Top level layout, puts the sliders to the left of the frame/GL widget
    //QHBoxLayout* hlayout = new QHBoxLayout( this);
    //hlayout->addWidget( ui->frame, 1 );
}

ViewPanel::~ViewPanel()
{
    delete ui;
}

void ViewPanel::setMyUI( MyGUI* _ui )
{
  c->setMyUI( _ui );
}

void ViewPanel::setUserOperation( int _oper, Qt::CursorShape _cursor )
{
  c->setUserOperation( _oper, _cursor );
  //c->initializeGL();
  //c->update();
}


void ViewPanel::setTopolViewFlag( int _type, bool _isVisible )
{
  c->setTopolViewFlag( _type, _isVisible );
}


void ViewPanel::setGridSnapData( bool _isVisible, bool _isSnapOn, double _dx, double _dy )
{
  c->setGridSnapData( _isVisible, _isSnapOn, _dx, _dy );
}



//-------------------------------------------------------------------------
bool 
ViewPanel::getGridSnapInfo( double& _dx, double& _dy )
{
  return c->getGridSnapInfo( _dx, _dy );
}
//-------------------------------------------------------------------------




bool ViewPanel::hasUndoing()
{
  return c->hasUndoing();
}

bool ViewPanel::hasRedoing()
{
  return c->hasRedoing();
}


Model* ViewPanel::getModel()
{
  return c->getModel();
}


void ViewPanel::createPoint (double _x, double _y, double _tol)
{
   c->createPoint( _x, _y, _tol);
}
void ViewPanel::createLine (double _x1, double _x2, double _y1, double _y2, double _tol)
{
   c->createLine( _x1, _x2, _y1, _y2, _tol);
}